using Microsoft.SqlServer.Management.Smo;
using System;

namespace Microsoft.SqlServer.Management.SqlManagerUI.Scripting
{
    using Server = Microsoft.SqlServer.Management.Smo.Server;
	internal class ScriptApplicationRoleCommand : ScriptObjectCommand
	{
		public ScriptApplicationRoleCommand(Server server, ObjectScriptedHandler scriptTarget, ScriptActions scriptAction) : base(server, scriptTarget, scriptAction)
		{
		}

		protected override void ScriptPermission(SqlSmoObject smoObject, ScriptingOptions options, ObjectScriptedHandler scriptTargetHandler)
		{
			ApplicationRole applicationRole = smoObject as ApplicationRole;
			if (applicationRole == null)
			{
				base.ScriptPermission(smoObject, options, scriptTargetHandler);
				return;
			}
			if (applicationRole.Parent.Parent.Information.Version.Major >= 9)
			{
				base.ScriptPermission(smoObject, options, scriptTargetHandler);
			}
		}
	}
}
